unit O_AlphaPanel;

interface

uses
  Classes,ExtCtrls,Messages, Windows, Controls, Graphics, Dialogs, Forms;
type
  TAlphaPanel = class(TPanel)
  public
    procedure WMPaint(var Msg: TMessage); message WM_Paint;
    constructor Create(AOwner: TComponent); override;
  end;

  TAlphaWindow = class(TCustomForm)
  published
    property OnClick;
  public
    constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0);override;
  end;


implementation

{ TAlphaPanel }

constructor TAlphaPanel.Create(AOwner: TComponent);
begin
  inherited;
  Self.BevelOuter := bvNone;
  Self.Color := clFuchsia;
end;

procedure TAlphaPanel.WMPaint(var Msg: TMessage);
procedure AlphaBlendTabControl;
  var
    MemBitmap, OldBitmap: HBITMAP;
    BF: BLENDFUNCTION;
    MemDC, DC: HDC;
  begin
    if (Parent = nil) or not Parent.HandleAllocated then
      Exit;
    DC := GetDC(0);
    MemBitmap := CreateCompatibleBitmap(DC, Parent.Width, Parent.Height);
    ReleaseDC(0, DC);
    MemDC := CreateCompatibleDC(0);
    OldBitmap := SelectObject(MemDC, MemBitmap);
    try
      Parent.Perform(WM_ERASEBKGND, MemDC, MemDC);
      Parent.Perform(WM_PAINT, MemDC, 0);

      BF.SourceConstantAlpha := 100;
      BF.AlphaFormat := 0;
      BF.BlendOp := AC_SRC_OVER;
      BF.BlendFlags := 0;
      Windows.AlphaBlend(Canvas.Handle, 0, 0, Width, Height, MemDC, Left,  Top, Width, Height, BF);
    finally
      SelectObject(MemDC, OldBitmap);
      DeleteDC(MemDC);
      DeleteObject(MemBitmap);
    end;
  end;
begin
  inherited;
  AlphaBlendTabControl;
end;

{ TAlphaWindow }



constructor TAlphaWindow.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
  inherited;
  self.AlphaBlend := True;
  self.AlphaBlendValue := 180;
  Self.BorderStyle := bsNone;
  Self.Color := clFuchsia;
  Self.Ctl3D := False;
end;

end.
